home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / TPLAS20.ZIP / TPLAS11.ZIP / PLASDAT.C next >
Encoding:
C/C++ Source or Header  |  1994-03-20  |  4.1 KB  |  119 lines

  1. /************************************************************************
  2.  *                                                                      *
  3.  *    PlasmDat.C     Generate palette, movement, random data file for   *
  4.  *                         TomsPlas (TPlas.ASM)                            *
  5.  *                                                                      *
  6.  *        An FPU helps a *lot* on this!  But it's acceptably fast on a        *
  7.  *                386sx-16, given the fact that it need only be run on          *
  8.  *                average once every 32,000 runs or so of tplas.com.                *
  9.  *                                                                      *
  10.  *        This is revision 1.1 of the data file generator.  It is *NOT*        *
  11.  *                compatible with earlier versions of tplas!  If your version    *
  12.  *                of tplas.com is later than revision 1.1, check the tplas        *
  13.  *                manual to see if this revision of the data file is still        *
  14.  *                applicable!                                                                    *
  15.  *                                                                      *
  16.  ************************************************************************/
  17.  
  18. #define XDIM   320      /*  change if we change tplas.asm  */
  19. #define VER        1.1
  20.  
  21. #include <stdio.h>
  22. #include <stdlib.h>
  23. #include <math.h>
  24. #include <time.h>
  25.  
  26. /*****  Function Prototypes for C:\PLASDAT.C  *****/
  27. void  main(void);
  28.  
  29.  
  30. void  main(void)
  31.     {
  32.     signed int i;
  33.     unsigned int rval;
  34.     long unsigned count;
  35.     int   lead,offset;
  36.     FILE  *fp;
  37.  
  38.     printf("\nTom's Plasma Data Generation, (C) Tom Dibble 1994\n");
  39.     printf("\tRevision %1.1g\n\n",VER);
  40.  
  41.     if (!(fp=fopen("TOMSPLASM.DAT","wb")))
  42.         {
  43.         printf("\7Cant open output file TOMSPLASM.DAT\n");
  44.         exit(-1);
  45.         }
  46.  
  47.     /*  Arbitrary movement for two pointers  */
  48.     /*  Size is 10000*4 = 40,000 bytes  */
  49.     /*  These pointers are the offset from (0,0) on the main function
  50.                 from which each of the two overlaid screens is taken.
  51.                 The first term defines how the screen is moving horizontally,
  52.                 the second how it is moving vertically.  Make sure neither of
  53.                 these values is ever negative!  */
  54.     /*  The 'offset' value has the 'lead' value subtracted from it.  I don't
  55.                 know why...  */
  56.     /*  Finally, the numbers.  In the term '60+59*cos(...)', the cos()
  57.                 term varies between -1 and 1.  Therefore, the whole term
  58.                 varies between 1 and 119.  This means that the first
  59.                 pixel horizontally are never shown, but the other edge is
  60.                 never overrun either.  The 'y' term of this varies
  61.                 between 1 and 99.  The last five pixels vertically are
  62.                 never shown.  I don't know why this is.
  63.  
  64.                 The numbers themselves ...  changing the numbers within
  65.                 the sin() and cos() functions will make the picture
  66.                 wobble more (with lower numbers) or less (higher
  67.                 numbers).
  68.  
  69.                 Putting more of a difference in the two numbers will
  70.                 make the screen change more drastically with each
  71.                 update.
  72.  
  73.             */
  74.  
  75.    printf("\n\tGenerating Movement Pointers \t==========\b\b\b\b\b\b\b\b\b\b");
  76.    for (count=0;count<10000;count++)
  77.       {
  78.       if(count%1000 == 999)
  79.          printf(">");   /*  ten dots  */
  80.  
  81.       lead=           60+59.0*cos((double)count/32)
  82.               +XDIM*(int)(50+49*sin((double)count/16));
  83.       offset=         60+59.0*sin((double)count/21)
  84.               +XDIM*(int)(50+49*cos((double)count/24))
  85.            -lead;
  86.       fwrite(&lead,2,1,fp);
  87.       fwrite(&offset,2,1,fp);
  88.       }
  89.  
  90.     /*  And a smooth transition colour lookup table */
  91.     /*  Size is (256*4)*3 =3,072 bytes  */
  92.  
  93.     printf("\n\tGenerating Color Palette \t==========\b\b\b\b\b\b\b\b\b\b");
  94.     for (i=0; i<256*4; i++)
  95.         {
  96.         if( (i%(102)) == (102)-1)
  97.             printf(">");
  98.  
  99.         fputc((sin((double)i/20)*sin((double)i/15)*31+31),fp);
  100.         fputc((sin((double)i/35)*sin((double)i/22)*31+31),fp);
  101.         fputc((sin((double)i/13)*sin((double)i/30)*31+31),fp);
  102.         }
  103.  
  104.     /*  Finally, 64k of random numbers.  */
  105.     randomize();
  106.     printf("\n\tAnd now, Random Values \t\t==========\b\b\b\b\b\b\b\b\b\b");
  107.     for (count=0; count < 0x8000 ; count++)
  108.         {
  109.         if( (count % 3276) == 3275)
  110.             printf(">");   /*  ten dots  */
  111.         rval=rand();
  112.         fwrite(&rval,2,1,fp);
  113.         }
  114.  
  115.     fclose(fp);
  116.     printf("\nNow, that wasn't so bad ...  was it?\n");
  117.     }
  118.  
  119.